package cn.stylefeng.guns.modular.manage.controller;

import cn.stylefeng.guns.core.common.page.LayuiPageFactory;
import cn.stylefeng.guns.modular.manage.service.OrderService;
import cn.stylefeng.guns.modular.manage.warpper.OrderWarpper;
import cn.stylefeng.roses.core.base.controller.BaseController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author (作者):mf-mazhenyu
 * @version (版本信息)： Copyright 2013 版权所有
 * @company：美福科技
 * @package cn.stylefeng.guns.modular.manage.order.controller
 * @title 文件名：OrderController
 * @date 日期：2019/7/15 10:16
 */

@Controller
@RequestMapping("/order")
public class MyOrderController extends BaseController {
    private String PREFIX = "/modular/manage/order/";

    @Autowired
    private OrderService orderService;

    @RequestMapping("")
    public String index() {
        return PREFIX + "order.html";
    }

    @RequestMapping("/order_add")
    public String orderAdd() {
        return PREFIX + "order_add.html";
    }

    @RequestMapping("/order_update/{orderId}")
    public String orderUpdate(@PathVariable Integer orderId, Model model) {
        return PREFIX + "/order_edit.html";
    }

    @RequestMapping("/list")
    @ResponseBody
    public Object list(@RequestParam(value = "condition", required = false) String condition) {

        Page<Map<String, Object>> list = this.orderService.list(condition);
        Page<Map<String, Object>> wrap = new OrderWarpper(list).wrap();
        return LayuiPageFactory.createPageInfo(wrap);
    }
}
